﻿using System;
using System.Web.UI;
using System.Drawing.Imaging;

namespace INHollandair.Account
{
    public partial class CaptchaImage : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["CaptchaImageText"] != null)
            {
                // Create a CAPTCHA image using the text stored in the Session object.
                var ci = new Core.Models.CaptchaImage(Session["CaptchaImageText"].ToString(), 220, 50);

                // Change the response headers to output a JPEG image.
                Response.Clear();
                Response.ContentType = "image/jpeg";

                // Write the image to the response stream in JPEG format.
                ci.Image.Save(Response.OutputStream, ImageFormat.Jpeg);

                Response.Write(ci);

                // Dispose of the CAPTCHA image object
                ci.Dispose();
            }
        }
    }
}